package com.sun.lg.utils;

import com.sun.lg.anno.Autowired;
import com.sun.lg.anno.Component;

import java.sql.SQLException;
@Component
public class TransactionManager {
    @Autowired
    private ConnectionUtils connectionUtils;

    public void setConnectionUtils(ConnectionUtils connectionUtils) {
        this.connectionUtils = connectionUtils;
    }

    public void beginTransaction() throws SQLException {
        connectionUtils.getCurreentThreadConnection().setAutoCommit(false);
    }

    public void commit() throws SQLException {
        connectionUtils.getCurreentThreadConnection().commit();
    }

    public void rollback() throws SQLException {
        connectionUtils.getCurreentThreadConnection().rollback();
    }


}
